package com.coment.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import java.time.LocalDateTime;

public class BasePO {
   @JsonSerialize(
      using = LocalDateTimeSerializer.class
   )
   @JsonDeserialize(
      using = LocalDateTimeDeserializer.class
   )
   @JsonFormat(
      pattern = "yyyy-MM-dd HH:mm:ss",
      timezone = "GMT+8"
   )
   public LocalDateTime createTime = LocalDateTime.now();
   @JsonSerialize(
      using = LocalDateTimeSerializer.class
   )
   @JsonDeserialize(
      using = LocalDateTimeDeserializer.class
   )
   @JsonFormat(
      pattern = "yyyy-MM-dd HH:mm:ss",
      timezone = "GMT+8"
   )
   public LocalDateTime updateTime = LocalDateTime.now();
   @JsonSerialize(
      using = LocalDateTimeSerializer.class
   )
   @JsonDeserialize(
      using = LocalDateTimeDeserializer.class
   )
   @JsonFormat(
      pattern = "yyyy-MM-dd HH:mm:ss",
      timezone = "GMT+8"
   )
   public LocalDateTime deleteTime;
   public Integer baseStatus = 1;

   public void update() {
      this.updateTime = LocalDateTime.now();
   }

   public void delete() {
      this.deleteTime = LocalDateTime.now();
      this.baseStatus = -1;
   }
}
